/**
@file
	TServiceModule.h
@brief
	Interface for Service Module.
@author
	GengYong
@revision
	2005/11/05 * Created by GengYong.
*/


#ifndef SAF_HEADER_FILE_SERVICEMODULETEMPLATE_H
#define SAF_HEADER_FILE_SERVICEMODULETEMPLATE_H

#undef  SERVICEMODULEINTERFACE
#if defined(WIN32)
#define SERVICEMODULEINTERFACE	_declspec(dllexport)
#else
#define SERVICEMODULEINTERFACE
#endif

#include "KernelExport.h"

// Declare service module
#define DECLARE_SERVICE_MODULE														\
extern "C" SERVICEPROXYINTERFACE SAF::DEFINE::MODULEDESCRIPTION	Description;		\
extern "C" SERVICEPROXYINTERFACE void * Builder(unsigned long, void *);				\
extern "C" SERVICEPROXYINTERFACE void Destroyer(void *);

// Implement service module
#define IMPLEMENT_SERVICE_MODULE(name, copyright, description)						\
	SAF::DEFINE::MODULEDESCRIPTION	Description = {									\
			SAF::DEFINE::MODULEDESCRIPTION::VERSION,								\
			SAF::DEFINE::SERVICEMODULENAME,											\
			#copyright,																\
			#description,															\
			__TIME__ ", " __DATE__};												\
	void * Builder(unsigned long version, void *)									\
	{																				\
		REGISTER_PERFCOUNTER(#name);												\
		if (version == SAF::DEFINE::MODULEDESCRIPTION::VERSION)						\
		{																			\
			return new name ();														\
		}																			\
		return 0;																	\
	}																				\
	void Destroyer(void * p) { delete (name *)(p); }

#endif	//#ifndef SAF_HEADER_FILE_SERVICEMODULETEMPLATE_H

